package com.ruoyi.framework.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @description: OSS配置
 * @author: Marvin
 * @create: 2024-12-30 00:09
 */
@Component
@ConfigurationProperties(prefix = "oss")
public class OssConfig {

    /** OSS域名 */
    public static String endpoint;

    /** OSS地址 */
    public static String ossAddrs;

    /** 访问Id */
    public static String accessKeyId;

    /** 访问密钥 */
    public static String accessKeySecret;

    /** OSS存储空间 */
    public static String bucketName;

    public static String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        OssConfig.endpoint = endpoint;
    }

    public static String getAccessKeyId() {
        return accessKeyId;
    }

    public void setAccessKeyId(String accessKeyId) {
        OssConfig.accessKeyId = accessKeyId;
    }

    public static String getAccessKeySecret() {
        return accessKeySecret;
    }

    public void setAccessKeySecret(String accessKeySecret) {
        OssConfig.accessKeySecret = accessKeySecret;
    }

    public static String getBucketName() {
        return bucketName;
    }

    public void setBucketName(String bucketName) {
        OssConfig.bucketName = bucketName;
    }

    public static String getOssAddrs() {
        return ossAddrs;
    }

    public void setOssAddrs(String ossAddrs) {
        OssConfig.ossAddrs = ossAddrs;
    }

    @Bean
    public OSS ossClient() {
        return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    }
}
